﻿namespace ToolMonitoring.WebApi.Extensions
{
	public static class StringExtension
	{
		public static string TruncateWithPostfix(this string input, int maxLength, string postfix = "...")
		{
			if (input.Length <= maxLength)
			{
				// 字符串长度小于等于最大长度，无需截断
				return input;
			}
			else
			{
				// 截断字符串并添加后缀
				return input.Substring(0, maxLength - postfix.Length) + postfix;
			}
		}

	}
}
